﻿namespace FreshMeat.Storage
{
   /// <summary>
   /// Simple struct describing the result of a load operation.
   /// </summary>
   /// <typeparam name="TData"></typeparam>
   public struct StoreLoadResult<TData>
   {
      readonly bool found;
      readonly TData data;

      /// <summary>
      /// Creates instance.
      /// </summary>
      /// <param name="found">Whether the data was found.</param>
      /// <param name="data">The data, which is only valid if <paramref name="found"/> is true.</param>
      public StoreLoadResult(bool found, TData data)
      {
         this.found = found;
         this.data = data;
      }

      /// <summary>
      /// Indicates whether the data was found.
      /// </summary>
      public bool Found
      {
         get { return found; }
      }

      /// <summary>
      /// The data that was found or default(TData).
      /// </summary>
      public TData Data
      {
         get { return data; }
      }
   }
}